/*
 * EditAlignmentDialog.java
 *
 * Created on 24 de Fevereiro de 2009, 19:16
 */

package ontoTree.ontoTree;

import javax.swing.JRadioButton;

/**
 *
 * @author  Ligia
 */
public class EditAlignmentDialog extends javax.swing.JDialog {
 
    public static final int RET_CANCEL = 0;
    public static final int RET_OK = 1;

    /** Creates new form EditAlignmentDialog */
    public EditAlignmentDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

  
   
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonAlignGroup = new javax.swing.ButtonGroup();
        btnOKMap = new javax.swing.JButton();
        btnCancelMap = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        radioBtnEquiv = new javax.swing.JRadioButton();
        radioBtnSubsume = new javax.swing.JRadioButton();
        radioBtnSubsumed = new javax.swing.JRadioButton();
        radioBtnIncomp = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        txtSimi = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Editar Mapeamento");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        btnOKMap.setText("OK");
        btnOKMap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOKMapActionPerformed(evt);
            }
        });

        btnCancelMap.setText("Cancelar");
        btnCancelMap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelMapActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel2.setText("Editar Mapeamento");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(168, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        buttonAlignGroup.add(radioBtnEquiv);
        radioBtnEquiv.setText("Equivalência");

        buttonAlignGroup.add(radioBtnSubsume);
        radioBtnSubsume.setText("Subsume");

        buttonAlignGroup.add(radioBtnSubsumed);
        radioBtnSubsumed.setText("Subsumed");

        buttonAlignGroup.add(radioBtnIncomp);
        radioBtnIncomp.setText("Incompativel");

        jLabel1.setText("Similaridade:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(radioBtnEquiv, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(radioBtnSubsumed)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(radioBtnSubsume)
                            .addComponent(radioBtnIncomp)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(txtSimi, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(42, 42, 42))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioBtnEquiv)
                    .addComponent(radioBtnSubsume))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioBtnIncomp)
                    .addComponent(radioBtnSubsumed))
                .addGap(32, 32, 32)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtSimi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(89, 89, 89)
                .addComponent(btnOKMap, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCancelMap)
                .addContainerGap(102, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelMap)
                    .addComponent(btnOKMap))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnOKMapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKMapActionPerformed
 doClose(RET_OK);
}//GEN-LAST:event_btnOKMapActionPerformed

private void btnCancelMapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelMapActionPerformed
  doClose(RET_CANCEL);
}//GEN-LAST:event_btnCancelMapActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
  doClose(RET_CANCEL);
}//GEN-LAST:event_formWindowClosing
  
private void doClose(int retStatus) {
         if(radioBtnEquiv.isSelected())
           relationship = Relationship.Equiv;
        else if(radioBtnSubsume.isSelected())
               relationship = Relationship.Subsume;
        else if(radioBtnSubsumed.isSelected())
            relationship = Relationship.Subsumed;
        else if(radioBtnIncomp.isSelected())
            relationship =Relationship.Incompat;
        else relationship = null;
        simi = txtSimi.getText();
        returnStatus = retStatus;
        setVisible(false);
        dispose();
    }
 /** retorna status */
    public int getReturnStatus() {
        return returnStatus;
    }
    
    public Relationship getRelationship(){
        return relationship;
       
    }
    
    public void setRelationship(Relationship rel){
        relationship = rel;
         if(rel == Relationship.Equiv)
             radioBtnEquiv.setSelected(true);
      
        else if(rel == Relationship.Subsume)
               radioBtnSubsume.setSelected(true);
        else if(rel == Relationship.Subsumed)
            radioBtnSubsumed.setSelected(true);
        else if(rel == Relationship.Incompat)
            radioBtnIncomp.setSelected(true);
   
       
    }
    
    public String getSimi(){
        return simi;
    }
    public void setSimi(String sim){
        simi = sim;
        txtSimi.setText(simi);
    }
  
    private int returnStatus = RET_CANCEL;
    private Relationship relationship;
    private String simi;

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelMap;
    private javax.swing.JButton btnOKMap;
    private javax.swing.ButtonGroup buttonAlignGroup;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JRadioButton radioBtnEquiv;
    private javax.swing.JRadioButton radioBtnIncomp;
    private javax.swing.JRadioButton radioBtnSubsume;
    private javax.swing.JRadioButton radioBtnSubsumed;
    private javax.swing.JTextField txtSimi;
    // End of variables declaration//GEN-END:variables

}
